package com.aniu.smslisten.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.aniu.smslisten.service.SmsListenService;
import com.aniu.smslisten.util.LogToFile;

public class SystemBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "SystemBroadcastReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        LogToFile.log(context, TAG, "SystemBroadcastReceiver onReceive called with action: " + action);

        // 判断SmsListenService是否正在运行
        if (!SmsListenService.isServiceRunning(context)) {
            LogToFile.log(context, TAG, "SmsListenService is not running, restarting...");
            Intent serviceIntent = new Intent(context, SmsListenService.class);
            context.startForegroundService(serviceIntent);
        }
        else {
//            SmsListenService.scheduleWorkManagerAlarm(context);
        }
    }
}
